/****************************************************************************************
 Copyright © 2003-2012 ZTEsoft Corporation. All rights reserved. Reproduction or       <br>
 transmission in whole or in part, in any form or by any means, electronic, mechanical <br>
 or otherwise, is prohibited without the prior written consent of the copyright owner. <br>
 ****************************************************************************************/
package com.iwhalecloud.bss.kite.cucc.service.attr.handler;

import com.alibaba.fastjson.JSONObject;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttrValue;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import com.iwhalecloud.bss.kite.service.attr.handler.AbstractAttrHandler;
import com.ztesoft.bss.base.util.LocalAttrUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * <Description> <br>
 * POP点
 */

public class POPAttrHandler extends AbstractAttrHandler<KiteInst, AttrData> {

    @Override
    public void before(KiteAttr attr, KiteInst inst, String value, AttrData data) {
       super.before(attr, inst, value, data);
    }

    @Override
    public void set(KiteAttr attr, KiteInst inst, String value, AttrData data) {
        super.set(attr, inst, value, data);
    }

    @Override
    public void after(KiteAttr attr, KiteInst inst, AttrData data){
        if(null==attr.getValue()){
            List<JSONObject> pops =LocalAttrUtils.getInstance().qryPopData(null);
            List<KiteAttrValue>  attrValues= new ArrayList<>();
            KiteAttrValue kiteAttrValue0 = new KiteAttrValue();
            kiteAttrValue0.setAttrValue("");
            kiteAttrValue0.setAttrId("202110151406");
            kiteAttrValue0.setAttrValueName("--请选择--");
            kiteAttrValue0.setSortBy("0");
            attrValues.add(kiteAttrValue0);
            for(JSONObject jo : pops){
                KiteAttrValue kiteAttrValue = new KiteAttrValue();
                kiteAttrValue.setAttrValue(jo.getString("STATION_CODE"));
                kiteAttrValue.setAttrValueName(jo.getString("STATION_NAME"));
                kiteAttrValue.setAttrValueDesc(jo.getString("STATION_NAME"));
                kiteAttrValue.setAttrId("202110151406");
                kiteAttrValue.setSortBy("1");
                attrValues.add(kiteAttrValue);
            }
            attr.setAttrValues(attrValues);
        }
        super.after(attr, inst, data);
    }



}
